package edu.hrbu.util;

import edu.hrbu.vo.MyPageInfo;

public class PageUtil {

    public static MyPageInfo doPageInfo(int dataCount, int pageSize, int nowPage) {
        MyPageInfo pageInfo = null;
        // 总页数
        int pageCount = (dataCount%pageSize == 0)? (dataCount/pageSize): dataCount/pageSize + 1;
        // 是否有上一页。下一页
        boolean hasPrePage = nowPage > 1;
        boolean hasTailPage = nowPage < pageCount;
        pageInfo = new MyPageInfo(dataCount, pageCount, (nowPage-1)*pageSize, hasPrePage, hasTailPage, nowPage);
        return pageInfo;
    }

    public static void main(String[] args) {
        MyPageInfo pageInfo = PageUtil.doPageInfo(10, 3, 2);
        System.out.println(pageInfo);
    }

}
